class Animal{
    int num = 1;
   public void fun(){
        System.out.println("父类中的方法");
    }
}

class  Dog extends Animal{
    int num = 10;

    @Override
    public void fun(){
        System.out.println("子类中的方法");
    }

    public void dogg(){
        System.out.println("子类中特有的方法");
    }
}

public class demo {

    public static void main(String[] args) {
        /*Animal animal = new Dog();
        animal.fun();*/


        Dog dog = new Dog();
        Animal animal = new Dog();


        if(animal instanceof Dog){
            animal.fun();
            //animal.dogg();
            dog = (Dog)animal;
            dog.fun();
            dog.dogg();
        }else {
            System.out.println("类型不匹配");
        }


    }
}
